-- card: 3055 from stack: in.9 -- bmap block id: 3273 -- flags: 0000 -- background id: 2661 -- name: -- part 1 (field) -- low flags: 01 -- high flags: 0007 -- rect: left=69 top=68 right=252 bottom=434 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 12 -- part name: -- part 22 (button) -- low flags: 80 -- high flags: 2005 -- rect: left=0 top=326 right=342 bottom=18 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: -- part 25 (button) -- low flags: 00 -- high flags: A003 -- rect: left=209 top=278 right=318 bottom=335 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: CopyRes ----- HyperTalk script ----- on mouseUp get FilePath("STAK","Prov stack :") if it is empty then exit mouseUp put it into ProvFile get FilePath("STAK","Dest stack :") if it is empty then exit mouseUp put it into DestFile ask "Resource type :" with "XCMD" if it is empty then exit mouseUp put it into ResType ask "Resource name or ID :" with "CopyRes" if it is empty then exit mouseUp put it into ResName answer "Optionnal parameter :" with "R" or "I" or "None" if it is "None" then CopyRes ProvFile,DestFile,ResType,ResName else CopyRes ProvFile,DestFile,ResType,ResName,it get the Result if first word of it is "Error" then beep answer it else answer "Copy done, result = “" & it & "”" end mouseUp -- part contents for card part 1 ----- text ----- CopyRes 1.9 XCMD by Frédéric RINALDI DESCRIPTION ------------ CopyRes is a XCMD allowing to copy resources between two files. Unlike ResCopy, it doesn't simply replace existing resources with same name or ID without warning, and offers a wide range of error checking. SYNTAX ------- CopyRes ,,,[,] PARAMETERS ------------ Prov and dest file can be name or full pathname. With a single name, the file is assumed to be in the same folder than the current stack. Using "*" for any of these parameters will refer to the current stack pathname. Res type must be a four char string, and is case sensitive. The resource to copy can be invoked by its name or its ID. Last parameter is optionnal, and can be any string beginning with "I", "R" or "K". Its allows to automatically renumber the copied resource, either Incremental or Random. Incremental will set an ID equal to the highest ID of the type plus one. Random will set any ID no already existing and over 1000. Using "K" (Krunch) will not ask what to do with existing resource having same name or ID and simply replace it. Using "!" and "?" parameter will return an online help (resp. copyright and syntax). USING ----- In case of name or ID conflict, the XCMD will bring an ask dialog allowing to rename or renumber the resource to copy. Renumbering dialog proposes another non-existing ID. Clicking Cancel will abort the copy. If the same name or ID is kept, then a second answer dialog pops to get confirmation for replacing the previous resource. Clicking Yes replaces the resource, No returns to first dialog and Cancel aborts the copy. If the copy succeeds, The Result will return a two items string containing the name and ID of the copied resource. If any error occurs, or the copy is aborted, the Result can return : "Error : Missing Parameter(s)" "Error : Param 5 must begin with R,I or K" "Error : Bad Resource Type" "Error : Same dest and prov file" "Error : Volume Not Found" "Error : File Not Found" "Error : Path Not Found" "Error : Unknown #xx" "Error : Resource not found" "Error : Copy failed" "Error : Copy aborted" HISTORY -------- 1.9 : 12/25/91 • Added file alias handling 1.8 : • Added "K" param 1.7 : • Changed DetachResource to HandtoHand to avoid errors with HC 2.0. 1.6 : • code cleaned ACKNOWLEDGEMENT ------------------ This stack uses FilePath XFCN, © 1898, 1990 Apple Computer, Inc. -------------------------------------------------------------------- This (these) external(s) is (are) FreeWare,allowing unlimited use in any non-commercial stack. You just need in this case to mention the author's name and copyright in your stack. Any commercial use must be licensed and aknowledged by the author. © F. Rinaldi - 1989,1990,1991 AppleLink: RINALDI1 CalvaCom : FR10 Compuserve : 71170,2111